﻿@model IEnumerable<RedSand.Site.Models.CategoryInfo>
<div class="panel">
    <div class="panel-header">
        <span>Category</span>
    </div>
    <div class="panel-content">
        <div class="panel-toolbar">
            <ul>
                <li>
                    @Ajax.ActionLink("Add category", "create", new { count = Model == null ? 0 : Model.Count() }, AdminAjaxOptions.GetForm, new { @class = "btn-create" })
                </li>
                <li>
                    @Ajax.ActionLink("Back", "list", new { level = 1, parent = 0 }, AdminAjaxOptions.GetList, new { @class = "btn-back" })
                </li>
            </ul>
        </div>
        @if (Model == null)
        {
            <div class="message warning">Data empty</div>
        }
        else
        {
            <table class="table-list">
                <thead>
                    <tr>
                        <th>
                            Name
                        </th>
                        <th class="center width-100">
                            Is popular
                        </th>
                        <th class="center width-100">
                            For custom pc
                        </th>
                        <th class="center width-100">
                            Status
                        </th>
                        <th class="center width-80">
                            Control
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {
                        <tr>
                            <td>
                                @Ajax.ActionLink(item.Name, "List", new { parent = item.CategoryID, level = 3 }, AdminAjaxOptions.GetList)
                            </td>
                            <td class="center">
                                @((item.IsPopular.HasValue && item.IsPopular.Value) ? "yes" : "no")
                            </td>
                            <td class="center">
                                @((item.ForCustomPc.HasValue && item.ForCustomPc.Value) ? "yes" : "no")
                            </td>
                            <td class="center">
                                @DropDownListHelper.GetStatusString(item.Status)
                            </td>
                            <td class="center">
                                @Ajax.ActionLink("Edit", "edit", new { id = item.CategoryID, count = Model.Count() }, AdminAjaxOptions.GetForm, new { @class = "btn-edit", title = "Edit" })
                                @Ajax.ActionLink("Delete", "delete", new { id = item.CategoryID }, AdminAjaxOptions.DeleteRecord, new { @class = "btn-delete", title = "Delete" })
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        }
    </div>
</div>
